package com.activity_01;

//import com.example.test_project_01.R;

//import com.activity_01.Activity_01.BTN2Listener;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.*;


public class Activity_04 extends Activity {
	private TextView TVRST;
	private TextView TVSend;
	private Button BTNSMS;
	private String RST;
	//private EditText ETNo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity04);
        TVRST = (TextView)findViewById(R.id.TVRST);
        TVSend = (TextView)findViewById(R.id.TVSend);
        //ETNo = (EditText)findViewById(R.id.ETNo);
        BTNSMS = (Button)findViewById(R.id.BTNSMS);
        Intent intent = getIntent();
        String factoroneStr = intent.getStringExtra("one");
        String factortwoStr = intent.getStringExtra("two");
        int factoroneInt = Integer.parseInt(factoroneStr);
        int factortwoInt = Integer.parseInt(factortwoStr);
        int result = factoroneInt * factortwoInt;
        RST = result + "";
        TVRST.setText(result + "");
        TVSend.setText(R.string.SMS);
        BTNSMS.setText(R.string.Send);
        BTNSMS.setOnClickListener(new BTNSMSListener());
        
    }
    
    
    class BTNSMSListener implements View.OnClickListener{
    	@Override
    	public void onClick(View v) {
    		//String ETNoStr = ETNo.getText().toString();
    		//int ETNoInt = Integer.parseInt(ETNoStr);
    		Uri uri = Uri.parse("smsto:");
    		Intent intent = new Intent(Intent.ACTION_SENDTO,uri);
    		intent.putExtra("sms_body", RST);
    		startActivity(intent);
    		}
    	} 
    
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		menu.add(0,1,1,R.string.exit);
		menu.add(0,2,2,R.string.about);
		return super.onCreateOptionsMenu(menu);
	}



	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		if(item.getItemId() == 1){
			finish();
		}
		else{
			if(item.getItemId() == 2){
				Intent intent = new Intent();
				intent.setClass(Activity_04.this, Activity_02.class);
			}
		}
		
		return super.onOptionsItemSelected(item);
	}
}